package com.jianglin.mapper;

import com.jianglin.model.Repairtype;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
@SuppressWarnings("SpellCheckingInspection")
public interface RepairtypeMapper {

    @Select("SELECT * FROM repairtype")
    List<Repairtype> findAll();

    @Select("SELECT * FROM repairtype WHERE id = #{id}")
    Repairtype findById(Long id);

    @Insert("<script>" +
            "INSERT INTO repairtype " +
            "<trim prefix='(' suffix=')' suffixOverrides=','>" +
            "   <if test='name != null'>name,</if>" +
            "   <if test='remarks != null'>remarks,</if>" +
            "   <if test='status != null'>status</if>" +
            "</trim>" +
            "<trim prefix='VALUES (' suffix=')' suffixOverrides=','>" +
            "   <if test='name != null'>#{name},</if>" +
            "   <if test='remarks != null'>#{remarks},</if>" +
            "   <if test='status != null'>#{status}</if>" +
            "</trim>" +
            "</script>")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Repairtype repairtype);

    @Update("<script>" +
            "UPDATE repairtype " +
            "<set>" +
            "   <if test='name != null'>name = #{name},</if>" +
            "   <if test='remarks != null'>remarks = #{remarks},</if>" +
            "   <if test='status != null'>status = #{status}</if>" +
            "</set>" +
            "WHERE id = #{id}" +
            "</script>")
    int update(Repairtype repairtype);

    @Delete("DELETE FROM repairtype WHERE id = #{id}")
    int delete(Long id);

    @Select("SELECT * FROM repairtype WHERE id = #{typeId}")
    Repairtype findTypeById(Long typeId);
}
